import request from '../utils/request';


export default {
    // 查询不包括下发部门和本身的部门列表（任务不能向上下发）
    avoidCycleDepartment(yearTargetId,targetId,type,level,acceptDeptId){
        return request({
            url: `/target/avoidCycleDepartment`,
            method: 'get',
            params: {
                yearTargetId,
                targetId,
                type,
                level,
                acceptDeptId,
            }
        })       
    },
    // 查询所有的目标任务
    getAllWorkOfYearTarget() {
        return request({
            url: `/target/getAll2`,
            method: 'get'
        })
    },
    getDepartC(id,type,allocDeptId){
        return request({
            url: `/target/findTargetByAllocDeptAndType/${id}`,
            method: 'get',
            params: {
                type,
                allocDeptId
            }
        });
    },
    // 根据年度目标的Id，和ABC类请求数据
    getWorkOfYearTarget(id, type) {
        return request({
            url: `/target/findByType/${id}`,
            method: 'get',
            params: {
                type
            }
        });
    },
    // 根据年度目标的Id，和ABC类请求数据
    getWorkOfYearTarget2(id, type) {
        return request({
            url: `/target/findByType2/${id}`,
            method: 'get',
            params: {
                type
            }
        });
    },
    addWorkOfYearTarget(id, type, target1) {
        var data1 = {
            id: target1.id,
            number: target1.number,
            yearTargetId: id,
            name: target1.name,
            type: target1.type,
            level: target1.level,
            allocUserId: target1.allocUserId,
            allocDeptId: target1.allocDeptId,
            acceptDeptId: target1.acceptDeptId,
            isAssess: target1.isAssess,
            requirement: target1.requirement,


        }
        console.log("1111111111");
        console.log(target1);
        console.log("11111111");
        let level = target1.level
        let targetId = target1.parentId

        return request({
            url: `/target/addByType/${id}/${type}`,
            method: 'post',
            params: {
                level,
                targetId
            },
            data: data1

        });
    },
    // 删除目标任务
    removeWorkOfYearTarget(id) {
        return request({
            url: `/target/delete`,
            method: 'delete',
            params: {
                id
            }
        });
    },
    // 编辑目标任务
    editWorkOfYearTarget(id, target) {
        return request({
            url: `/target/update/${id}`,
            method: 'put',
            data: target
        });
    },
    // 通过id获取年度目标任务
    getWorkOfYearTargetById(id) {
        return request({
            url: `/target/get2/${id}`,
            method: 'get',
        });
    },
    // 通过id获取年度目标任务
    getWorkNameOfYearTargetById(id) {
            return request({
                url: `/target/get/${id}`,
                method: 'get',
            });
        },



    //年度目标二级任务查询
    getTargetTwo(id, level, acceptDeptId) {
        return request({
            url: `/target/findNextTarget/${id}`,
            method: 'get',
            params: {
                level,
                acceptDeptId
            }
        });
    },
}